package com.situ.mall.order.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.situ.mall.common.util.Result;
import com.situ.mall.order.entity.query.OrderInfoQuery;
import com.situ.mall.order.entity.vo.OrderInfoVO;
import com.situ.mall.order.service.IOrderInfoService;
import com.situ.mall.pojo.entity.order.OrderInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 订单 前端控制器
 * </p>
 *
 * @author Z
 * @since 2024-10-14
 */
@RestController
@RequestMapping("/order/orderInfo")
public class OrderInfoController {
    @Autowired
    private IOrderInfoService orderInfoService;
    @RequestMapping("/add")
    public Result add(@RequestBody OrderInfo orderInfo) {
        //orderInfo里面有userId和addressId
        orderInfoService.add(orderInfo);
        return Result.ok("添加成功");
    }
    @RequestMapping("/list")
    public Result list( OrderInfoQuery orderInfoQuery) {
        System.out.println("OrderInfoController.list");
        System.out.println("userId:" + orderInfoQuery.getUserId());
        IPage<OrderInfoVO> orderInfoVOS = orderInfoService.list(orderInfoQuery);
        return Result.ok(orderInfoVOS);
    }
}

